package com.cs307.redcross.client;

import java.util.Vector;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@RemoteServiceRelativePath("databaseHandler")
public interface DatabaseHandlerService extends RemoteService{

        public  void recreateDB() throws Exception;

        public int getNextID() throws Exception;
        
        //check log-in info
        public Boolean validUser(String s) throws Exception;
        
        public boolean forgotPassword(String user) throws Exception;

        public  int validPassword(String user, String password)
                        throws Exception;

        public void sendInvitation(Vector<Person> people, Event event, String message) throws Exception;
        
        //methods to check if an object is in the DB by checking the item's id
        public  Boolean inDB(Administrator a) throws Exception;

        public  Boolean inDB(Event a) throws Exception;

        public  Boolean inDB(FreeTimeEvent a) throws Exception;

        public  Boolean inDB(EventTemplate a) throws Exception;

        public  Boolean inDB(Group a) throws Exception;

        public  Boolean inDB(Volunteer a) throws Exception;

        public  Boolean inDB(Reminder a) throws Exception;
        
        public Boolean inDB(ReminderTemplate a) throws Exception;

        //get items
        public  Person getPerson(int id) throws NumberFormatException,
                        Exception;

        public  Person getPerson(String user) throws NumberFormatException,
                        Exception;

        public  Administrator getAdmin(int id)
                        throws NumberFormatException, Exception;

        public  Volunteer getVolunteer(int id)
                        throws NumberFormatException, Exception;

        public  Event getEvent(int id) throws Exception; //TODO: make getters for the vectors
        

        public  FreeTimeEvent getFreeTimeEvent(int id) throws Exception; //TODO: make getters for the vectors
        

        public  FreeTimeEvent getFreeTimeEvent(int id, Person p)
                        throws Exception; //TODO: make getters for the vectors
        

        public  EventTemplate getEventTemplate(int id) throws Exception; //TODO: make getters for the vectors


        public  Group getGroup(int id) throws Exception;

        public  Group getGroup(String name) throws Exception;

        public  Reminder getReminder(int id) throws Exception //TODO: make getters for the vectors
        ;

        public ReminderTemplate getReminderTemplate(int id) throws Exception;
        
        public LogFileEntry getLogFileEntry(int id) throws Exception;
        
        //get all of a certain type
        public  Vector<Administrator> getAllAdmins() throws Exception;

        public  Vector<Volunteer> getAllVolunteers() throws Exception;

        public  Vector<Person> getAllPeople() throws Exception;

        public  Vector<Event> getAllEvents() throws Exception;

        public  Vector<EventTemplate> getAllEventTemplates()
                        throws Exception;

        public  Vector<Group> getAllGroups() throws Exception;

        public  Vector<Reminder> getAllReminders() throws Exception;
        
        public Vector<ReminderTemplate> getAllReminderTemplates() throws Exception;
        
        public Vector<LogFileEntry> getAllLogFileEntries() throws Exception;

        //deletion commands
        public  boolean delete(Person a) throws Exception;

        public  boolean delete(Event a) throws Exception;

        public  boolean delete(FreeTimeEvent a) throws Exception;

        public  boolean delete(EventTemplate a) throws Exception;

        public  boolean delete(Group a) throws Exception;

        public  boolean delete(Reminder a) throws Exception;
        
        public boolean delete(ReminderTemplate a) throws Exception;
        
        

        //special case getters
        public  Vector<Reminder> getReminders(Event e)
                        throws NumberFormatException, Exception;

        public  Vector<Event> getEvents(Group g)
                        throws NumberFormatException, Exception;

        /**
         * 
         * @param p -Get all of the events to which this person belongs
         * @param includeGroups -If true, search for events that this person belongs to by virtue of being a member of a group.  If false, include only events that the person belongs to explicitly.
         * @return List of events to which the person belongs
         * @throws NumberFormatException
         * @throws Exception
         */
        public  Vector<Event> getEvents(Person p, boolean includeGroups)
        
                        throws NumberFormatException, Exception;

        public  Vector<Event> getEvents(Person p)
                        throws NumberFormatException, Exception;

        public  Vector<Group> getGroups(Person p)
                        throws NumberFormatException, Exception;

        public  Reminder getNextReminder() throws Exception;

        public  Event getNextEvent() throws Exception;

        //write commands
        public  int write(Administrator a) throws Exception;

        public  int write(Volunteer a) throws Exception;

        public  int write(Event a) throws Exception;

        public  int write(FreeTimeEvent a) throws Exception;

        public  int write(EventTemplate a) throws Exception;

        public  int write(Group a) throws Exception;

        public  int write(Reminder a) throws Exception;

        public int write(ReminderTemplate a) throws Exception;
        
        public void startDatabaseHandler() throws Exception;
        
        public boolean sendSMS(Vector<Person> people, String message, String subject);
        
        public Administrator convertToAdmin(Volunteer v) throws Exception;
        
        public void sendConfirmation(Volunteer v) throws Exception;
        
        public boolean confirm(String code) throws Exception;
        
        public boolean checkWithServerIfSessionIdIsStillLegal(int sessionID) throws Exception;
        
        public Person getUserFromSessionId(int sessionID) throws Exception;
        
        public Vector<Event> getAllFutureEvents() throws Exception;
}